/*
 * Project Name: showtao
 * File Name: VehicleModelFeature.java
 * Class Name: VehicleModelFeature
 *
 * Copyright 2014 showtao.com
 *
 * Licensed under the showtao.com
 *
 * http://showtao.com
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.showtao.front.dto.upstream;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.showtao.front.domain.VehicleModelFeature;

@SuppressWarnings("serial")
public class VehicleModelFeatureSavingDto implements Serializable {

	private Long id;
	private String name;
	private String categoryNumber;
	private boolean changed;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCategoryNumber() {
		return categoryNumber;
	}

	public void setCategoryNumber(String categoryNumber) {
		this.categoryNumber = categoryNumber;
	}
	
	public boolean isChanged() {
		return changed;
	}

	public void setChanged(boolean changed) {
		this.changed = changed;
	}

	@Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        } else if (!this.getClass().isInstance(obj)) {
            return false;
        }
        return new EqualsBuilder().append(id, ((VehicleModelFeatureSavingDto) obj).getId())
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(id).toHashCode();
    }
	
	public static Collection<VehicleModelFeatureSavingDto> from(
	        Collection<VehicleModelFeature> entities){
	    Collection<VehicleModelFeatureSavingDto> dtos = 
	               new ArrayList<VehicleModelFeatureSavingDto>();
	    
	    for(VehicleModelFeature entity : entities){
	        VehicleModelFeatureSavingDto dto = new VehicleModelFeatureSavingDto();
	        dto.setId(entity.getId());
	        dto.setName(entity.getName());
	        dto.setCategoryNumber(entity.getCategoryNumber());
	        dtos.add(dto);
	    }
	    
	    return dtos;
	}
}
